package com.zyg.jas.studentport.service.impl;

import com.zyg.jas.common.pojo.Article;
import com.zyg.jas.studentport.dao.ArticleDao;
import com.zyg.jas.studentport.service.ArticleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
@Service
public class ArticleServiceImpl implements ArticleService {
    private Logger logger = LoggerFactory.getLogger(ArticleServiceImpl.class);
    @Autowired
    private ArticleDao articleDao;
    @Override
    public void addArticle(Article article) {
        article.setPublishData(new Date());
        this.articleDao.publishArticle(article);
    }

    @Override
    public List<Article> getAllArticle() {
        List<Article> list = this.articleDao.selectAllArticle();
        return list;
    }

    @Override
    public List<Article> getMyArticle(String userId) {
        List<Article> list = this.articleDao.selectMyArticle(userId);
        return list;
    }

    @Override
    public void delArticleById(Integer id) {
        this.articleDao.deleteArticleById(id);
    }

    @Override
    public void modifyMyArticle(Integer id) {
        this.articleDao.modifyArticleById(id);
    }

    @Override
    public List<Article> searchByTitle(String title) {
        return this.articleDao.searchByName(title);
    }
}
